home *** CD-ROM | disk | FTP | other *** search
- head 1.2;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.2
- date 89.01.13.11.49.52; author douglis; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 89.01.06.12.36.39; author douglis; state Exp;
- branches ;
- next ;
-
-
- desc
- @Void any user log records for the current host.
- @
-
-
- 1.2
- log
- @tell Db_Open how many records to buffer.
- @
- text
- @/*
- * Ulog_ClearLogins.c --
- *
- * Source code for the Ulog_ClearLogins procedure.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/ulog/RCS/Ulog_ClearLogins.c,v 1.1 89/01/06 12:36:39 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- #endif not lint
-
-
- #include <ulog.h>
- #include "ulogInt.h"
-
-
- /*
- *----------------------------------------------------------------------
- *
- * Ulog_ClearLogins --
- *
- * Void any user log records for the current host.
- *
- * Results:
- * 0 on success, -1 if an error occurs (and errno will indicate the
- * nature of the error).
- *
- * Side effects:
- * The 'user log' is opened and locked while it is being modified.
- *
- *----------------------------------------------------------------------
- */
-
-
- int
- Ulog_ClearLogins()
- {
- char myHostName[ULOG_LOC_LENGTH];
- char buffer[ULOG_RECORD_LENGTH];
- Host_Entry *hostPtr;
- Db_Handle handle;
- int errnoTmp;
- int i;
-
- if (gethostname(myHostName, ULOG_LOC_LENGTH) < 0) {
- syslog(LOG_ERR, "Ulog_ClearLogins: error in gethostname.\n");
- return(-1);
- }
- hostPtr = Host_ByName(myHostName);
- Host_End();
- if (hostPtr == (Host_Entry *) NULL) {
- syslog(LOG_ERR,
- "Ulog_ClearLogins: error in Host_ByName for current host.\n");
- return(-1);
- }
-
- if (Db_Open(ULOG_FILE_NAME, ULOG_RECORD_LENGTH, &handle, 1,
- DB_LOCK_OPEN, DB_LOCK_BREAK, 0) < 0) {
- return(-1);
- }
-
- bzero(buffer, ULOG_RECORD_LENGTH);
- (void) sprintf(buffer, ULOG_FORMAT_STRING, -1, hostPtr->id, -1,
- 0, "(none)");
-
- /*
- * Write the first entry, specifying the location. Then do writes
- * sequentially (avoiding seeks).
- */
-
- if (Db_Put(&handle, buffer, hostPtr->id * ULOG_MAX_PORTS) < 0) {
- goto error;
- }
-
- for (i = 1; i < ULOG_MAX_PORTS; i++) {
- if (Db_Put(&handle, buffer, -1) < 0) {
- goto error;
- }
- }
- if (Db_Close(&handle) < 0) {
- return(-1);
- }
- return(0);
-
-
- /*
- * On error, try to close the database, but make sure to return
- * the error in errno that came from the error that made us quit.
- */
- error:
- errnoTmp = errno;
- (void) Db_Close(&handle);
- errno = errnoTmp;
-
- return(-1);
- }
-
-
-
-
-
-
-
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: Ulog_ClearLogins.c,v 1.3 88/09/15 10:16:58 douglis Exp $ SPRITE (Berkeley)";
- d66 1
- a66 1
- DB_LOCK_OPEN, DB_LOCK_BREAK) < 0) {
- @
-